package leetcode.medium.q80;

public class Main {

    public static void main(String[] args) {
        System.out.println(new Solution()
                .removeDuplicates(new int[]{0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4}));
    }
}

class Solution {
    //00100011111-->
    public int removeDuplicates(int[] nums) {
        int i = 2, k =  2;

        for (; k < nums.length; ) {
            if (nums[i-2] != nums[k]) {
                nums[i++]=nums[k++];
            } else {
                k++;
            }
        }
        return i;
    }
}